<?php

namespace app\admin\controller\wanlshop;

use think\Exception;
use WanlPay\Yansongda\Pay;

class Test
{
    protected $config = [
        'app_id' => '2017122201077772',
        'notify_url' => 'http://donghuomu.jiuhuanmall.com/UFKBjJMEZO.php/admin/wanlshop/test/notify',
        'return_url' => 'http://donghuomu.jiuhuanmall.com/UFKBjJMEZO.php/admin/wanlshop/test/return',
        'ali_public_key' => 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAhhYnLK5+dyQ3ft8gy7rDJStiv8q93Libinwak0+alpj55dWDazTRmIU5SDkmmHET25yTxtTYcYmbE8P9SNSGnqPaEwj0h7AEpkiobTf/RoCvNFu22b7aMBD0PaP1N6D5o4W4g+2dhfHPW/YvIaQVpQe3lt95CHuG4I8BscFwFDMwB/FTz5F3QDrJ0uI40WFRv44pb2iwnkEtUxEUqLHa6mE4AoXsiub4HAd8YXBf4EjMhqlWsttwTdo21nYy7cHw6AxlOh7jYPutzR7i3W9FokCk5IoW0Xl0qMihWQ7/krQdq5eqL9nmZs2Ha3LgjsCr7L+QDpVB8MkJAwAKXzmVswIDAQAB',
        // 加密方式： **RSA2**
        'private_key' => 'MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCVizNwVjD/xVh1NBY4/lYvKhx1fVwK5BvY2ZJjat518K+nJCR4szXwrfuJZoRBTuZxwMd9G5x44EwdHUjBwdkqSSzm5btNE84WvHF7KupJuT59eSd18w06v2qrhuriZLFOAaGKsd4hM0oGWr3FeACCz1e99oGVMi5+EH/uUmZOL/ey+V7IFxOi2P+fGeNcUq4u5zVoC8sUCrRk3mRLwTHqiaBhBYUhIBwtK4XlKZXW4YdmYP5M3eDL10rXqI+6MmK5Ogf1gcawTFyD1sCmhS/RS+z6OsotyAqDqnMrrmOKaPC1t9rAft+yuaKCcQrkjDIhqPPp7pCyT+gVkNG9KujjAgMBAAECggEADVsCPA0mkSEx1j3RokNstQegxQluF/bpWcOMpF5eAdB+D4JV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j8IUVAS8wSLlUjv8El7hc+0q9WaN5Lf6bW4PboNsMK++JuaUpFrOiB3Jp5OFWanscpOSI1Vf3A7M6GA==',
        'log' => [ // optional
            'file' => './logs/alipay.log',
            'level' => 'info', // 建议生产环境等级调整为 info，开发环境为 debug
            'type' => 'single', // optional, 可选 daily.
            'max_file' => 30, // optional, 当 type 为 daily 时有效，默认 30 天
        ],
        'http' => [ // optional
            'timeout' => 5.0,
            'connect_timeout' => 5.0,
            // 更多配置项请参考 [Guzzle](https://guzzle-cn.readthedocs.io/zh_CN/latest/request-options.html)
        ],
        'mode' => 'dev', // optional,设置此参数，将进入沙箱模式
    ];

    public function index()
    {
        try {
            $order = [
                'out_trade_no' => '20230830123321',
                'total_amount' => '0.01',
                'subject' => 'test subject - 测试',
            ];

            $alipay = Pay::alipay($this->config);
            return json($alipay->app($order)->getContent());

        } catch (Exception $exception) {

            var_dump($exception->getMessage());
        }
        return $alipay;
    }

    public function find()
    {
        $alipay = Pay::alipay($this->config);
        $order = [
            'out_trade_no' => '20230830123321',
        ];
        $data = $alipay->verify();
        return $data;
    }
}